/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Cam_reporteDAOImpl implements orm.dao.Cam_reporteDAO {
	public Cam_reporte loadCam_reporteByORMID(String re_id_reporte) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return loadCam_reporteByORMID(session, re_id_reporte);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte getCam_reporteByORMID(String re_id_reporte) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return getCam_reporteByORMID(session, re_id_reporte);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte loadCam_reporteByORMID(String re_id_reporte, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return loadCam_reporteByORMID(session, re_id_reporte, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte getCam_reporteByORMID(String re_id_reporte, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return getCam_reporteByORMID(session, re_id_reporte, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte loadCam_reporteByORMID(PersistentSession session, String re_id_reporte) throws PersistentException {
		try {
			return (Cam_reporte) session.load(orm.Cam_reporte.class, re_id_reporte);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte getCam_reporteByORMID(PersistentSession session, String re_id_reporte) throws PersistentException {
		try {
			return (Cam_reporte) session.get(orm.Cam_reporte.class, re_id_reporte);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte loadCam_reporteByORMID(PersistentSession session, String re_id_reporte, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Cam_reporte) session.load(orm.Cam_reporte.class, re_id_reporte, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte getCam_reporteByORMID(PersistentSession session, String re_id_reporte, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Cam_reporte) session.get(orm.Cam_reporte.class, re_id_reporte, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte[] listCam_reporteByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return listCam_reporteByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte[] listCam_reporteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return listCam_reporteByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte[] listCam_reporteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Cam_reporte as Cam_reporte");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Cam_reporte[]) list.toArray(new Cam_reporte[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte[] listCam_reporteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Cam_reporte as Cam_reporte");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Cam_reporte[]) list.toArray(new Cam_reporte[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte loadCam_reporteByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return loadCam_reporteByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte loadCam_reporteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return loadCam_reporteByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte loadCam_reporteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Cam_reporte[] cam_reportes = listCam_reporteByQuery(session, condition, orderBy);
		if (cam_reportes != null && cam_reportes.length > 0)
			return cam_reportes[0];
		else
			return null;
	}
	
	public Cam_reporte loadCam_reporteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Cam_reporte[] cam_reportes = listCam_reporteByQuery(session, condition, orderBy, lockMode);
		if (cam_reportes != null && cam_reportes.length > 0)
			return cam_reportes[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateCam_reporteByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return iterateCam_reporteByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCam_reporteByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.CamRegPersistentManager.instance().getSession();
			return iterateCam_reporteByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCam_reporteByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Cam_reporte as Cam_reporte");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCam_reporteByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Cam_reporte as Cam_reporte");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte createCam_reporte() {
		return new orm.Cam_reporte();
	}
	
	public boolean save(orm.Cam_reporte cam_reporte) throws PersistentException {
		try {
			orm.CamRegPersistentManager.instance().saveObject(cam_reporte);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Cam_reporte cam_reporte) throws PersistentException {
		try {
			orm.CamRegPersistentManager.instance().deleteObject(cam_reporte);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Cam_reporte cam_reporte)throws PersistentException {
		try {
			if(cam_reporte.getTi_id_tipo_reporte() != null) {
				cam_reporte.getTi_id_tipo_reporte().cam_reporte.remove(cam_reporte);
			}
			
			return delete(cam_reporte);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Cam_reporte cam_reporte, org.orm.PersistentSession session)throws PersistentException {
		try {
			if(cam_reporte.getTi_id_tipo_reporte() != null) {
				cam_reporte.getTi_id_tipo_reporte().cam_reporte.remove(cam_reporte);
			}
			
			try {
				session.delete(cam_reporte);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Cam_reporte cam_reporte) throws PersistentException {
		try {
			orm.CamRegPersistentManager.instance().getSession().refresh(cam_reporte);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Cam_reporte cam_reporte) throws PersistentException {
		try {
			orm.CamRegPersistentManager.instance().getSession().evict(cam_reporte);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Cam_reporte loadCam_reporteByCriteria(Cam_reporteCriteria cam_reporteCriteria) {
		Cam_reporte[] cam_reportes = listCam_reporteByCriteria(cam_reporteCriteria);
		if(cam_reportes == null || cam_reportes.length == 0) {
			return null;
		}
		return cam_reportes[0];
	}
	
	public Cam_reporte[] listCam_reporteByCriteria(Cam_reporteCriteria cam_reporteCriteria) {
		return cam_reporteCriteria.listCam_reporte();
	}
}
